﻿@using CCTV.Common
@using CCTV.Web
@model CCTV.Common.CCTVCamera
@helper GetJSFunction(AppConstants.TandbergViscaCommandsEnum command)
{
    string.Format("callServerCommand('{0}')", command.ToString());
}
@{  
    var presets = new List<SelectListItem>();
    if(Model.PresetPositions != null && Model.PresetPositions.Count >0)
    {
        foreach(CCTV.Common.CCTVPreset preset in Model.PresetPositions)
        {
            presets.Add(new SelectListItem() { Text = preset.Name, Value = preset.Number.ToString() });
        }
        
    }   
}

   
	<script type="text/javascript">
        selectedSpeed = @Model.DefaultMovementSpeed;
	    $(function () {
	        $("#sliderSpeed").slider({
                range : "min",
	            value: @Model.DefaultMovementSpeed ,
	            min: @Model.MinMovementSpeed,
	            max: @Model.MaxMovementSpeed,
	            step: @Model.IncrementStepMovementSpeed,
	            slide: function (event, ui) {
	               selectedSpeed = ui.value;
                }
	        });


	    });
	</script>

<div id="mainContainer">
    <table class="rightMenuHolder" align="center">
        <tr>
            <td>
            </td>
            <td colspan="3" align="center"> @Html.MouseDownButton("btnWide", "Zoom-", 
            Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.ZoomWide.ToString()),
Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.ZoomStop.ToString()),
                 Utilities.GetButtonCSS()
                 )
          @Html.MouseDownButton("btnTele", "Zoom+",
                     Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.ZoomTele.ToString()),
                                   Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.ZoomStop.ToString()),
                          Utilities.GetButtonCSS() 
            )
                
            </td>
             <td>
            </td>
        </tr>
        <tr>
            <td rowspan="3" valign="middle">
            </td>
            <td>
            </td>
            <td class="backgroundMovement">
                @Html.MouseDownButton("btnUp", "Up",
                     Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MoveUp.ToString()),
                                   Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MovementStop.ToString()),
                          Utilities.GetButtonCSS()
            )
            </td>
            <td>
            </td>
             <td valign="middle" rowspan="3">
            </td>
        </tr>
        <tr>
           
            <td class="backgroundMovement">
                @Html.MouseDownButton("btnLeft", "<",
                     Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MoveLeft.ToString()),
                                   Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MovementStop.ToString()),
                          Utilities.GetButtonCSS() 
            )
            </td>
            <td class="backgroundMovement">
                @Html.NormalButton("btnStop", "Home",
                                   Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.Home.ToString()),
                          Utilities.GetButtonCSS() 
            )
            </td>
            <td class="backgroundMovement">
                @Html.MouseDownButton("btnRight", ">",
                     Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MoveRight.ToString()),
                                            Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MovementStop.ToString()),
                          Utilities.GetButtonCSS() 
            )
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td class="backgroundMovement">
                  @Html.MouseDownButton("btnDown", "Down",
                     Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MoveDown.ToString()),
                                   Utilities.GetJSFunction(AppConstants.TandbergViscaCommandsEnum.MovementStop.ToString()),
                          Utilities.GetButtonCSS()
            )
            </td>
            <td>
            </td>
        </tr>
        
        <tr>
            <td>
            </td>
            <td colspan="3" align="center"> 
            </td>
             <td>
            </td>
        </tr>
         <tr style="height: 80px">
            <td>
                <label class="smalllabel">PTZ speed:</label> 
            </td>
            <td colspan="4">
                <div id="sliderSpeed"></div>
            </td>
        </tr>
        <tr>
            <td>
                <label class="smalllabel">Preset:</label> 
            </td>
            <td colspan="4">
              @Html.DropDownList("lstPresets", presets, new {@class="listpreset", onmousedown="", size="5"})
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#lstPresets").change(function () {
            var camPos = $("#lstPresets").attr("value");
            var cmd = '@Html.Raw(AppConstants.TandbergViscaCommandsEnum.GetPreset.ToString())';
            if (camPos != "") {
                getPano(cmd, camPos);
            }
        });
    });
</script>